<template>
	<section>
		<!--工具条-->
		<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
			<el-form :inline="true" :model="filters">
				<!-- <el-form-item>
					<el-input v-model="filters.name" placeholder="设备IP"></el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="primary">查询</el-button>
				</el-form-item> -->
			</el-form>
		</el-col>

		<!--列表-->
		<el-table :data="deviceAlarms" highlight-current-row v-loading="listLoading" style="width: 100%;" :height="clientHeight">
			<el-table-column type="index" width="60">
			</el-table-column>
			<el-table-column prop="device_ip" label="设备IP">
			</el-table-column>
			<el-table-column prop="device_desc" label="设备描述">
			</el-table-column>
			<el-table-column prop="location" label="位置">
			</el-table-column>
			<el-table-column prop="device_abnormal_information" label="设备信息">
			</el-table-column>
			<el-table-column prop="update_time" label="报错时间">
			</el-table-column>
			<el-table-column prop="handling_situation_desc" label="处理情况">
			</el-table-column>
			<el-table-column prop="remark" label="备注">
			</el-table-column>
		</el-table>

		<!--工具条-->
		<el-col :span="24" class="toolbar">
			<el-pagination layout="prev, pager, next" @current-change="handleCurrentChange" :page-size="15" :total="total" style="float:right;">
			</el-pagination>
		</el-col>
	</section>
</template>

<script>
	import util from '../../common/js/util'
	//import NProgress from 'nprogress'
	import { deviceAlarmList } from '@/api/api';
    import { mapState } from 'vuex'

	export default {
		data() {
			return {
				filters: {
					name: ''
				},
				deviceAlarms: [],
				page: 1,
				total: 0,
				listLoading: false,
			}
		},
        computed: {
            ...mapState(
                {
                  'clientHeight': state => state.clientHeight
                }
            )
        },
		methods: {
			handleCurrentChange(val) {
				this.page = val;
				this.device_alarm_list();
			},
			//获取设备警报信息
			device_alarm_list() {
				this.listLoading = true;
				deviceAlarmList(this.page).then((res) => {
					if(res.data.status.errCode == '10002'){
						sessionStorage.removeItem('token');
						this.$message({
							message: res.data.status.message,
							type: 'warning'
				        });
				        setTimeout(() =>{
				        	this.router({path: '/login'})
				        }, 1500);
						return;
					}
					this.total = res.data.data.total
					this.deviceAlarms = res.data.data.data
					this.listLoading = false
				});
			},
		},
		mounted() {
			this.device_alarm_list();
		}
	}

</script>

<style scoped>

</style>